﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BiffenService.Model;
using BiffenService.Db;

namespace BiffenService.Control
{
    public class BookingControl
    {
        private static IBookingDb bookingDb = new BookingDb();
        
        /// <summary>
        /// A method that sends an int phone in order to receive a list og type booking from bookingDb
        /// Purpose to find one or more bookings from a specific phone number
        /// </summary>
        /// <param name="phone">int phone, the phonenumber of a customer or member</param>
        /// <returns>List of type Booking, a list of all bookings with the actual phone number</returns>
        public static List<Booking> FindBookingByPhone(int phone)
        {
            return bookingDb.FindBookingIdByPhone(phone);
        }

        /// <summary>
        /// A method that sends an int bookingId in order to receive a booking with the specific Id
        /// </summary>
        /// <param name="bookingId">int bookingId, the bookingId of a specific booking</param>
        /// <returns>A Booking object with the parameter bookingId</returns>
        public static Booking FindBookingById(int bookingId)
        {
            return bookingDb.FindBookingById(bookingId);
        }

        /// <summary>
        /// A method that send an object show of type Show in order to receive a List of type Booking
        /// </summary>
        /// <param name="show">Show show, a show of type Show</param>
        /// <returns>A list of type Booking, every booking containing the parameter show</returns>
        public List<Booking> GetBookingsForShow(Show show)
        {
            return bookingDb.GetBookingsForShow(show);
        }

        /// <summary>
        /// A method that deletes a booking from the bookingId
        /// </summary>
        /// <param name="bookingId">int bookingId, an Id of a booking</param>
        /// <returns>int result, amount of rows affected in the sql database</returns>
        public static int DeleteBookingById(int bookingId)
        {
            return bookingDb.DeleteBookingById(bookingId);
        }

        /// <summary>
        /// A method that inserts a booking into the database
        /// </summary>
        /// <param name="Status">int Status the status of the booking, if it is sold or reserved</param>
        /// <param name="PhoneNumber">int PhoneNumber the customers phonenumber</param>
        /// <param name="DiscountType">int DiscountType the type of the discount if it is study(1), senior(2) or none(3)</param>
        /// <param name="ShowId">int ShowId the Id of show wanted to reserve</param>
        /// <param name="Seats">List seats a List with all the seats wanted to reserve</param>
        /// <param name="MemberId">int MemberId the id of the member if the reservation is for a member</param>
        /// <returns>int result, the number of rows affected in the sql database</returns>
        public static int CreateBooking(int Status, int PhoneNumber, int DiscountType, int ShowId, List<int> Seats, int MemberId)
        {
            return bookingDb.CreateBooking(Status, PhoneNumber, DiscountType, ShowId, Seats, MemberId);
        }

        /// <summary>
        /// A method that set a discount value to a booking Object
        /// </summary>
        /// <param name="discountValue">int discountValue, a value that defines the discount on a specific booking</param>
        /// <param name="bookingId">int bookingId, an Id of a specific booking</param>
        public void setDiscountToBooking(int discountId, int bookingId)
        {
            Booking book = FindBookingById(bookingId);
            book.Discount = bookingDb.GetDiscount(discountId);
        }

        /// <summary>
        /// A method that marks a Booking as sold
        /// </summary>
        /// <param name="id">int id, the Id of a specific booking</param>
        /// <returns>int result, the number of rows affected in the sql database</returns>
        public static int MarkBookingAsSold(int id)
        {
            return bookingDb.MarkBookingAsSold(id);
        }
    }
}
